Skip to main content

All Questions

Tagged with
6votes
3answers
1kviews

Fast bitswap in assembly

Can the following code to swap two bits be optimized? ...
Johan's user avatar
6votes
2answers
1kviews

Shifting an 128-bit integer consisting of four 32-bit integers

For a little project of mine I have written two versions for shifting a 128-bit unsigned integer consisting of four 32-bit unsigned integers in x86 assembly. I cannot really decide which is better in ...
idlmn89's user avatar
7votes
5answers
270views

Assembler-program which reverses the content of EAX

Following exercise: Write a program that takes a number (of size 4 bytes) x as input, and then reverses all the bits of x, and outputs the result. By reversing all bits we mean that the ...
michael.zech's user avatar
32votes
3answers
7kviews

Decide if the sum of three numbers is even or odd

Exercise from an Assembly course I'm enrolled into: Write a program that takes three numbers x,y,z as input, and returns: 0 if (x+y+z) is even. 1 if (x+y+z) is odd. (Note that here ...
michael.zech's user avatar
1vote
1answer
2kviews

Decide if a number is even or odd by using bitwise operator

The following exercise is from an Assembler-course I'm taking: Write a program that takes a number x as input, and returns: 0 if x is even. 1 if x is odd. Full exercise-page here: ...
michael.zech's user avatar
3votes
2answers
1kviews

Assembly: Sum up the single bytes of a 32bit-register to a checksum

Exercise description: "Write a program that takes a double word (4 bytes) as an argument, and then adds all the 4 bytes. It returns the sum as output. Note that all the bytes are considered to be of ...
michael.zech's user avatar
6votes
6answers
20kviews

A simple assembly program to count the number of ones in a register

I made a simple assembly program to count the number of ones in a register. Since this is basically my first ever, I would like to hear what I can improve or if there are some major flaws in this one: ...
AdHominem's user avatar
4votes
0answers
188views

Parallel popcount of packed bytes

I want to do a popcount of bytes in an array. Not a total popcount of everything, but lots of little popcounts for every individual byte to determine the neighborhood count in GoL. The following ...
Johan's user avatar
2votes
1answer
181views

Routine to convert decimal digits to Densely Packed Decimal

I've written an amd64 assembly routine (in gas syntax using the System V calling convention) to convert three decimal digits to Densely packed decimal because I wasn't satisfied by the performance of ...
FUZxxl's user avatar
9votes
3answers
17kviews

Integer square root in x86 assembly (NASM)

This program calculates the square root of an unsigned 32-bit number with some bit fiddling to get a very close approximation, then one iteration of the Babylonian method to get an exact value. I don'...
Jintonation's user avatar
119votes
11answers
53kviews

Fastest way to clamp an integer to the range 0-255

I'm working on some image processing code that can generate pixel values outside of the normal range of 0 to 255, and I'd like to clamp them back into the valid range. I know that there are saturating ...
Mark Ransom's user avatar

close